#include "../apue.h"
#include <stdio.h>
#include <shadow.h>
#include <errno.h>
#include <unistd.h>

void all_spwd(void);
void pr_spwdent(const struct spwd *);

int main(void)
{
    all_spwd();
    return 0;

}

void all_spwd(void)
{
    struct spwd * sp;
    setspent();

    errno = 0;
    while ((sp = getspent()) != NULL)
    {
        pr_spwdent(sp);
        printf("\n");
    }
    endspent();

    if (errno != 0)
        err_sys("getspent failed");

}


void pr_spwdent(const struct spwd * sp)
{
    printf("user: %s\n", sp->sp_namp);

    printf("\tsp_pwdp: %s\n", sp->sp_pwdp);
    printf("\tsp_lastchg: %ld\n", sp->sp_lstchg);
    printf("\tsp_min: %ld\n", sp->sp_min);
    printf("\tsp_max: %ld\n", sp->sp_max);
    printf("\tsp_warn: %ld\n", sp->sp_warn);
    printf("\tsp_inact: %ld\n", sp->sp_inact);
    printf("\tsp_expire: %ld\n", sp->sp_expire);
    printf("\tsp_flag: %ld\n", sp->sp_flag);


}
